package com.example.aspects;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(2)
//@Aspect
public class ParamCheckAspect {

    @Around("execution(* com.example.day02.*.*(..))")
    public  Object around(ProceedingJoinPoint joinPoint){
        System.out.println("before==> 参数校验之前...");
        Object result=null;
        try {
            //调用目标方法
            result =joinPoint.proceed();
            System.out.println("result:"+result);

            System.out.println("后置返回==>参数~");
        } catch (Throwable e) {
            System.out.println("afterThrowing 参数校验~");
            e.printStackTrace();
        }finally {
            //后置通知--无论是否出现异常都会执行。。。。。
            System.out.println("after==>参数校验");
        }

        return  result;
    }
}
